def seq_search(items, key):
    """顺序查找"""
    for index, item in enumerate(items):
        if item == key:
            return index
    return -1


def bin_search(items, key):
    """二分查找"""
    start, end = 0, len(items) - 1
    while start <= end:
        mid = (start + end) // 2
        if key == items[mid]:
            return mid
        elif key > items[mid]:
            start = mid + 1
        else:
            end = mid - 1
    return -1


def main():
    items = [12, 25, 33, 56, 78, 89, 91]
    print(bin_search(items, 55))
    print(bin_search(items, 89))


if __name__ == '__main__':
    main()
